<?php

class NewsRecycleController extends BaseController
{
	
	public function actionIndex()
	{
		$model=new News('search');
		$model->unsetAttributes();  // clear any default values
		$model->zne_status=3;//筛选已删除的信息
		if(isset($_GET['News'])){
			$model->attributes=$_GET['News'];
		}

		$this->render('index',array(
			'model'=>$model,
		));
	}

	/**
	 * 单选，批量还原
	 */
	public function actionRestore()
	{
		//操作ID号格式处理
		if(isset($_GET['id'])){
			$id = $_GET['id'];
		}elseif(isset($_POST['ids'])){
			$id =$_POST['ids'];
		}else{
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
		}
		$id = is_array($id)?join(',',$id):(int)$id;
		//处理条件
		$criteria=new CDbCriteria;
		$criteria->addCondition("zne_id in ($id)");
		//修改内容
		$set = array('zne_status'=>'2');
		//执行操作
		if(News::model()->updateAll($set,$criteria)){
			//成功跳转
			$this->redirect(Yii::app()->request->urlReferrer);
		}
	}
	
	/**
	 * 单选，批量删除
	 */
	public function actionDelete()
	{
		//操作ID号格式处理
		if(isset($_GET['id'])){
			$id = $_GET['id'];
		}elseif(isset($_POST['ids'])){
			$id =$_POST['ids'];
		}else{
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
		}
		$id = is_array($id)?join(',',$id):(int)$id;
		//处理条件
		$criteria=new CDbCriteria;
		$criteria->addCondition("zne_id in ($id)");

		//执行操作
		if(News::model()->deleteAll($criteria)){
			//成功跳转
			$this->redirect(Yii::app()->request->urlReferrer);
		}
	}
}